package com.wandian.setting.mvvm.modifyphone;

import androidx.databinding.DataBindingUtil;
import android.os.Bundle;

import com.alibaba.android.arouter.facade.annotation.Route;
import com.mylib.libcore.config.RouterConfig;
import com.mylib.libcore.mvvm.BaseMVVMActivity;
import com.mylib.libcore.utils.StatusBarUtils;
import com.mylib.libcore.utils.ToastUtil;
import com.mylib.libcore.utils.UIUtils;
import com.wandian.setting.R;
import com.wandian.setting.databinding.SetActivityModifyPhoneBinding;

/**
 * @author Administrator
 * @date 2019/12/18-14:28
 * @description  修改手机号
 **/
@Route(path = RouterConfig.ROUTER_ACTIVITY_SETTING_MODIFY_PHONE)
public class ModifyPhoneActivity extends  BaseMVVMActivity<ModifyPhoneViewModel>  {

    private SetActivityModifyPhoneBinding dataBinding;

    @Override
    public void init(Bundle savedInstanceState) {
        dataBinding = DataBindingUtil.setContentView(this, R.layout.set_activity_modify_phone);
        dataBinding.setLifecycleOwner(this);
        dataBinding.setViewModel(mViewModel);
        initViewData();
        initClink();
    }
    private void initViewData(){
        //设置状态颜色和字体黑色
        StatusBarUtils.with(this,false)
                .setIsActionBar(false)
                .clearActionBarShadow()
                .setDrawable(getResources().getDrawable(com.mylib.libcore.R.drawable.sys_color))
                .init();
        dataBinding.bindSysToolBar.toolBarTvTitle.setText("修改手机号");
    }
    private void initClink(){
        dataBinding.bindSysToolBar.toolBarIvBack.setOnClickListener(v -> {
            finishhideSoftBoard();
            finish();
        });
        dataBinding.tvYzmBtn.setOnClickListener(v -> {
            if(UIUtils.isEmpty(dataBinding.etNewPhone.getText()) || dataBinding.etNewPhone.getText().toString().length() != 11){
                ToastUtil.show("请填写更改的手机号");
                return;
            }

        });
        dataBinding.tvModifyBtn.setOnClickListener(v -> {
            if(UIUtils.isEmpty(dataBinding.etNewPhone.getText()) || dataBinding.etNewPhone.getText().toString().length() != 11){
                ToastUtil.show("请填写更改的手机号");
                return;
            }
            if(UIUtils.isEmpty(dataBinding.etYzm.getText()) || dataBinding.etYzm.getText().toString().length() != 6){
                ToastUtil.show("请输入验证码");
                return;
            }

        });

    }

}
